package bsh;

import org.objectweb.asm.Opcodes;

import bsh.meta.AbstractFieldDescriptor;
import bsh.meta.FieldDescriptor;
import bsh.meta.TypeWrapper;

/**
 * @author takeshi
 */
public class FieldDescriptorImpl extends AbstractFieldDescriptor implements FieldDescriptor {

    private final String name;

    private final int modifiers;

    /**
     * @param declaringType {@link TypeWrapper}
     * @param fieldType {@link TypeWrapper}
     * @param name String
     */
    public FieldDescriptorImpl(TypeWrapper declaringType, TypeWrapper fieldType, String name) {
        this(declaringType, fieldType, name, Opcodes.ACC_PUBLIC);
    }

    /**
     * C'tor
     * 
     * @param declaringType the declared type of the field
     * @param fieldType the field type
     * @param name the field name
     * @param modifiers the field modifiers
     */
    public FieldDescriptorImpl(TypeWrapper declaringType, TypeWrapper fieldType, String name, int modifiers) {
        super(declaringType, fieldType);
        this.name = name;
        this.modifiers = modifiers;
    }

    /**
     * {@inheritDoc}
     */
    public String fieldName() {
        return this.name;
    }

    /**
     * {@inheritDoc}
     */
    public int asmModifiers() {
        return modifiers;
    }

    /**
     * {@inheritDoc}
     */
    public boolean isStatic() {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return "FieldDescriptorImpl [name=" + name + ", fieldType()=" + fieldType() + "]";
    }

}
